package com.winit.openapi.ups.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.winit.common.spi.context.CommandContext;
import com.winit.openapi.controller.BaseController;
import com.winit.openapi.model.RequestMsg;
import com.winit.openapi.model.ResponseMsg;
import com.winit.ups.spi.warehouse.PackageReceivingStandardService;
import com.winit.ups.spi.warehouse.command.QueryPackageRSCountryCodeCommand;
import com.winit.ups.spi.warehouse.vo.PackageReceivingStandardVo;


/**
 * 询收货标准
 * @author qibin.tang
 *
 */
@Controller
@RequestMapping(value = "/ups/packageReceivingStandard")
public class PackageReceivingStandardController extends BaseController{
    
    
    @Resource
    private PackageReceivingStandardService packageReceivingStandardService;
    
    /**
     * 根据国家编码查询收货标准
     * @param requestMsg
     * @param responseMsg
     * @return
     */
    @RequestMapping(value = "/query")
    public String queryEorIorList(@ModelAttribute RequestMsg requestMsg, @ModelAttribute ResponseMsg responseMsg) {
    	QueryPackageRSCountryCodeCommand command = JSON.parseObject(requestMsg.getData().toString(),QueryPackageRSCountryCodeCommand.class);
        command.setCtx(CommandContext.getContext());
        List<PackageReceivingStandardVo> list = packageReceivingStandardService.queryByCountryCode(command);
        Map<String, Object> data = new HashMap<String, Object>();
        data.put("packageReceivingStandard", list);
        responseMsg.setData(data);
        return SUCCESS;
    }
    

}
